package action.article;

import org.apache.struts2.ServletActionContext;

import service.ArticleService;
import service.UserService;
import bean.Article;
import bean.User;

import com.opensymphony.xwork2.ActionSupport;

public class EditArticleAction extends ActionSupport {
	private Article article;
	private ArticleService articleService;
	private UserService userService;
	
	@Override
	public String execute() throws Exception {
		article=articleService.getArticleById(article.getId());
		User u=(User) ServletActionContext.getContext().getSession().get("user");
		User user=userService.login(u);
		ServletActionContext.getRequest().setAttribute("user", user);
		if(article==null)
			return INPUT;
		else
			return SUCCESS;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	
}
